home *** CD-ROM | disk | FTP | other *** search
- Path: dinews.epfl.ch!usenet
- From: Bernhard Ruch <Bernhard.Ruch@studi.epfl.ch>
- Newsgroups: comp.lang.c++,gnu.g++.help
- Subject: Template function only for built-in types
- Date: Thu, 21 Mar 1996 21:21:12 +0100
- Organization: Ecole Polytechnique Federale de Lausanne
- Message-ID: <3151BA38.41C6@studi.epfl.ch>
- NNTP-Posting-Host: didec6.epfl.ch
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (X11; I; OSF1 V3.2 alpha)
-
- Is it possible to declare a template function that is
- valid only for the built-in types, but not for classes
- created by the user?
-
- I wanted to write the following template function:
-
-
- template <class T> InStream &operator >> (InStream &pInStream, T &t) {
-
- cin >> t;
-
- return (pInStream);
-
- }; //* operator >> *//
-
-
- class A {...};
-
-
- However, the compiler did not accept this, since the class istream
- contains no operator >> for the class A.
-
- I got the following message:
-
- Test.h:103: no match for `operator >>(class istream, class A)'
-
-
- Bernhard
-